package com.modi.breaks;

import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;

public class StretchScheduler {

	private ScheduledExecutorService scheduler;

	public StretchScheduler() {
		scheduler = Executors.newScheduledThreadPool(1);

	}

	public void startTheScheduler() {
		final Runnable breakNotifier = new Runnable() {
			public void run() {
				System.out.println("Log the strecth strat time"+DateUtils.now());
				StrecthFrame frame = StrecthFrame.INSTANCE;
				frame.label.setText("Start time-----"+DateUtils.now());
				Main.breakTime.add(DateUtils.now());
				frame.show();
				frame.setVisible(true);
				frame.toFront();
			}
		};
		scheduler.schedule(breakNotifier, Main.delay, TimeUnit.SECONDS);
	}

	public void stopTheScheduler() {
		scheduler.shutdownNow();
		scheduler = null;
	}

}
